package com.example.springdemo0921.spring;

import com.example.springdemo0921.Person;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author kusej
 * Create at 2022-09-21 16:44
 **/
public class MyRegister implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(Person.class);
        MutablePropertyValues propertyValues = new MutablePropertyValues();
        propertyValues.add("name","张三");
        rootBeanDefinition.setPropertyValues(propertyValues);
        registry.registerBeanDefinition("person",rootBeanDefinition);

    }
}
